package com.bnz.controller;


import com.bnz.pojo.Student;
import com.bnz.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    //查询所有学生
    @GetMapping("list")
    public String findAll(Model model){
        //查询所有学生
        List<Student> students = studentService.findAll();
        //将查询到的值放到模型中去
        model.addAttribute("student",students);
        //返回逻辑视图
        return "student/list";
    }
}
